package com.wy2.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wy2.entity.Message;
import com.wy2.entity.User;
import com.wy2.service.MessageService;
import com.wy2.util.FenyeUtil;

@RestController
@CrossOrigin
@RequestMapping("/message")
public class MessageController {
	@Autowired
	private MessageService messageService;
	/**
	 * 添加动态消息
	 * @param message
	 * @return
	 */
	@RequestMapping("/add")
		Integer addMessage(Message message) {
			message.setMetime(new Date());
			return messageService.addMessage(message);
			
		}
	
	/**
	 * 分页查询数据
	 * @param fenye
	 * @param message
	 * @return
	 */
	@GetMapping
	public FenyeUtil<Message> getAll( FenyeUtil<Message> fenye,Message message){
		//把查询所有的参数传到分页工具类
		fenye.setT(message);
		fenye = messageService.getAll(fenye);
		
		return fenye;
		
	}
	
}
